package com.zc.trendsDispatch.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.trendsDispatch.mapper.ChargeEngineRuleMapper;
import com.zc.trendsDispatch.domain.ChargeEngineRule;
import com.zc.trendsDispatch.service.IChargeEngineRuleService;

import static com.ruoyi.common.utils.SecurityUtils.getUsername;

/**
 * 规则策略Service业务层处理
 *
 * @author glb
 * @date 2024-03-11
 */
@Service
public class ChargeEngineRuleServiceImpl implements IChargeEngineRuleService
{
    @Autowired
    private ChargeEngineRuleMapper chargeEngineRuleMapper;

    /**
     * 查询规则策略
     *
     * @param ruleId 规则策略主键
     * @return 规则策略
     */
    @Override
    public ChargeEngineRule selectChargeEngineRuleByRuleId(Long ruleId)
    {
        return chargeEngineRuleMapper.selectChargeEngineRuleByRuleId(ruleId);
    }

    /**
     * 查询规则策略列表
     *
     * @param chargeEngineRule 规则策略
     * @return 规则策略
     */
    @Override
    public List<ChargeEngineRule> selectChargeEngineRuleList(ChargeEngineRule chargeEngineRule)
    {
        return chargeEngineRuleMapper.selectChargeEngineRuleList(chargeEngineRule);
    }

    /**
     * 新增规则策略
     *
     * @param chargeEngineRule 规则策略
     * @return 结果
     */
    @Override
    public int insertChargeEngineRule(ChargeEngineRule chargeEngineRule)
    {
        chargeEngineRule.setCreateBy(getUsername());
        chargeEngineRule.setCreateTime(DateUtils.getNowDate());
        return chargeEngineRuleMapper.insertChargeEngineRule(chargeEngineRule);
    }

    /**
     * 修改规则策略
     *
     * @param chargeEngineRule 规则策略
     * @return 结果
     */
    @Override
    public int updateChargeEngineRule(ChargeEngineRule chargeEngineRule)
    {
        chargeEngineRule.setUpdateBy(getUsername());
        chargeEngineRule.setUpdateTime(DateUtils.getNowDate());
        return chargeEngineRuleMapper.updateChargeEngineRule(chargeEngineRule);
    }

    /**
     * 批量删除规则策略
     *
     * @param ruleIds 需要删除的规则策略主键
     * @return 结果
     */
    @Override
    public int deleteChargeEngineRuleByRuleIds(Long[] ruleIds)
    {
        return chargeEngineRuleMapper.deleteChargeEngineRuleByRuleIds(ruleIds);
    }

    /**
     * 删除规则策略信息
     *
     * @param ruleId 规则策略主键
     * @return 结果
     */
    @Override
    public int deleteChargeEngineRuleByRuleId(Long ruleId)
    {
        return chargeEngineRuleMapper.deleteChargeEngineRuleByRuleId(ruleId);
    }
}
